package org.jeecg.modules.code.ry.service.impl;

import org.hibernate.query.internal.NativeQueryImpl;
import org.hibernate.transform.Transformers;
import org.jeecg.modules.code.ry.entity.SdsiPeopleRyTest;
import org.jeecg.modules.code.ry.mapper.SdsiPeopleRyTestMapper;
import org.jeecg.modules.code.ry.service.ISdsiPeopleRyTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.List;

/**
 * @Description: 人员表测试
 * @Author: jeecg-boot
 * @Date:   2021-10-24
 * @Version: V1.0
 */
@Service
public class SdsiPeopleRyTestServiceImpl extends ServiceImpl<SdsiPeopleRyTestMapper, SdsiPeopleRyTest> implements ISdsiPeopleRyTestService {

    @Autowired
    private EntityManager entityManager;

    //执行SQL
    public List<Object> execSqlStr(String sqlStr){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(sqlStr);
        Query query = entityManager.createNativeQuery(String.valueOf(stringBuilder));
        query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
        return query.getResultList();
    }

}
